package com.yxhl.km.module.view;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;

import com.yxhl.km.R;


/**
 * 张亚楠 on 2017/10/30.
 */
public class DiagUtil {
    public Dialog progressDialog;


    public static DiagUtil getInstance() {

        return SingHold.singStatic;
    }

    private static class SingHold {
        private static DiagUtil singStatic = new DiagUtil();

    }

    /**
     * 获取数据过程中显示的等待框
     */
    public void createWaitDialog(Activity activity) {
        if (progressDialog == null) {
            progressDialog = new Dialog(activity, R.style.progress_dialog);
            progressDialog.setContentView(R.layout.diaglog_loading);
            progressDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
            progressDialog.show();
            progressDialog.setCancelable(false);
        }
    }

    /**
     * 是否正在运行
     *
     * @param activity
     * @return
     */
    public boolean isDialog(Activity activity) {
        return progressDialog.isShowing();
    }


    /**
     * 取消对话框
     */
    public void closeWaitDialog() {
        if (null != progressDialog && progressDialog.isShowing()) {
            progressDialog.dismiss();
        } else {
            progressDialog = null;
        }
    }

}
